<?php
class Zend_View_Helper_WebPageScraping extends Zend_View_Helper_Abstract {
	
    public $view;
    
    public function setView(Zend_View_Interface $view) {
        $this->view = $view;
    }
    
	public function webPageScraping($url, $attrName, $attrValue, $itemCnt=0) {
		$data = @file_get_contents($url);
		if (empty($data))
			return null;
		$DOM = new DOMDocument();
		libxml_use_internal_errors(true);
		$DOM->loadHTML($data);
		$xpath = new DOMXPath($DOM);
		$value = $xpath->query("//*[@".$attrName."='".$attrValue."']")->item($itemCnt)->nodeValue;
		return $value;
	}
}
?>